{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.series.Series'>\n",
      "0    Avengers: Age of Ultron (2015)\n",
      "1                 Cinderella (2015)\n",
      "2                    Ant-Man (2015)\n",
      "3            Do You Believe? (2015)\n",
      "4     Hot Tub Time Machine 2 (2015)\n",
      "Name: FILM, dtype: object\n",
      "0    74\n",
      "1    85\n",
      "2    80\n",
      "3    18\n",
      "4    14\n",
      "Name: RottenTomatoes, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "fandaogo = pd.read_csv('fandango_score_comparison.csv')\n",
    "series_film = fandaogo['FILM']\n",
    "print(type(series_film))\n",
    "print(series_film.head(5))\n",
    "series_rt = fandaogo['RottenTomatoes']\n",
    "print(series_rt.head(5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n",
      "Minions (2015)      54\n",
      "Leviathan (2014)    99\n",
      "dtype: int64\n",
      "---------------------\n",
      "The Water Diviner (2015)        63\n",
      "Irrational Man (2015)           42\n",
      "Top Five (2014)                 86\n",
      "Shaun the Sheep Movie (2015)    99\n",
      "Love & Mercy (2015)             89\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "from pandas import Series\n",
    "film_names = series_film.values\n",
    "print(type(film_names))\n",
    "rt_scores = series_rt.values\n",
    "series_custom = Series(rt_scores, index=film_names)\n",
    "print(series_custom[['Minions (2015)', 'Leviathan (2014)']])\n",
    "print('---------------------')\n",
    "print(series_custom[5:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'71 (2015)                    97\n",
      "5 Flights Up (2015)           52\n",
      "A Little Chaos (2015)         40\n",
      "A Most Violent Year (2014)    90\n",
      "About Elly (2015)             97\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "original_index = series_custom.index.tolist()\n",
    "sorted_index = sorted(original_index)\n",
    "sorted_by_index = series_custom.reindex(sorted_index)\n",
    "print(sorted_by_index.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paul Blart: Mall Cop 2 (2015)     5\n",
      "Hitman: Agent 47 (2015)           7\n",
      "Hot Pursuit (2015)                8\n",
      "Fantastic Four (2015)             9\n",
      "Taken 3 (2015)                    9\n",
      "The Boy Next Door (2015)         10\n",
      "The Loft (2015)                  11\n",
      "Unfinished Business (2015)       11\n",
      "Mortdecai (2015)                 12\n",
      "Seventh Son (2015)               12\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "sc2 = series_custom.sort_index()\n",
    "sc3 = series_custom.sort_values()\n",
    "print(sc3[0:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Avengers: Age of Ultron (2015)                    148\n",
      "Cinderella (2015)                                 170\n",
      "Ant-Man (2015)                                    160\n",
      "Do You Believe? (2015)                             36\n",
      "Hot Tub Time Machine 2 (2015)                      28\n",
      "The Water Diviner (2015)                          126\n",
      "Irrational Man (2015)                              84\n",
      "Top Five (2014)                                   172\n",
      "Shaun the Sheep Movie (2015)                      198\n",
      "Love & Mercy (2015)                               178\n",
      "Far From The Madding Crowd (2015)                 168\n",
      "Black Sea (2015)                                  164\n",
      "Leviathan (2014)                                  198\n",
      "Unbroken (2014)                                   102\n",
      "The Imitation Game (2014)                         180\n",
      "Taken 3 (2015)                                     18\n",
      "Ted 2 (2015)                                       92\n",
      "Southpaw (2015)                                   118\n",
      "Night at the Museum: Secret of the Tomb (2014)    100\n",
      "Pixels (2015)                                      34\n",
      "McFarland, USA (2015)                             158\n",
      "Insidious: Chapter 3 (2015)                       118\n",
      "The Man From U.N.C.L.E. (2015)                    136\n",
      "Run All Night (2015)                              120\n",
      "Trainwreck (2015)                                 170\n",
      "Selma (2014)                                      198\n",
      "Ex Machina (2015)                                 184\n",
      "Still Alice (2015)                                176\n",
      "Wild Tales (2014)                                 192\n",
      "The End of the Tour (2015)                        184\n",
      "                                                 ... \n",
      "Clouds of Sils Maria (2015)                       178\n",
      "Testament of Youth (2015)                         162\n",
      "Infinitely Polar Bear (2015)                      160\n",
      "Phoenix (2015)                                    198\n",
      "The Wolfpack (2015)                               168\n",
      "The Stanford Prison Experiment (2015)             168\n",
      "Tangerine (2015)                                  190\n",
      "Magic Mike XXL (2015)                             124\n",
      "Home (2015)                                        90\n",
      "The Wedding Ringer (2015)                          54\n",
      "Woman in Gold (2015)                              104\n",
      "The Last Five Years (2015)                        120\n",
      "Mission: Impossible â€“ Rogue Nation (2015)       184\n",
      "Amy (2015)                                        194\n",
      "Jurassic World (2015)                             142\n",
      "Minions (2015)                                    108\n",
      "Max (2015)                                         70\n",
      "Paul Blart: Mall Cop 2 (2015)                      10\n",
      "The Longest Ride (2015)                            62\n",
      "The Lazarus Effect (2015)                          28\n",
      "The Woman In Black 2 Angel of Death (2015)         44\n",
      "Danny Collins (2015)                              154\n",
      "Spare Parts (2015)                                104\n",
      "Serena (2015)                                      36\n",
      "Inside Out (2015)                                 196\n",
      "Mr. Holmes (2015)                                 174\n",
      "'71 (2015)                                        194\n",
      "Two Days, One Night (2014)                        194\n",
      "Gett: The Trial of Viviane Amsalem (2015)         200\n",
      "Kumiko, The Treasure Hunter (2015)                174\n",
      "Length: 146, dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "print(np.add(series_custom, series_custom))\n",
    "np.sin(series_custom)\n",
    "np.max(series_custom)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Avengers: Age of Ultron (2015)                                            74\n",
      "The Water Diviner (2015)                                                  63\n",
      "Unbroken (2014)                                                           51\n",
      "Southpaw (2015)                                                           59\n",
      "Insidious: Chapter 3 (2015)                                               59\n",
      "The Man From U.N.C.L.E. (2015)                                            68\n",
      "Run All Night (2015)                                                      60\n",
      "5 Flights Up (2015)                                                       52\n",
      "Welcome to Me (2015)                                                      71\n",
      "Saint Laurent (2015)                                                      51\n",
      "Maps to the Stars (2015)                                                  60\n",
      "Pitch Perfect 2 (2015)                                                    67\n",
      "The Age of Adaline (2015)                                                 54\n",
      "The DUFF (2015)                                                           71\n",
      "Ricki and the Flash (2015)                                                64\n",
      "Unfriended (2015)                                                         60\n",
      "American Sniper (2015)                                                    72\n",
      "The Hobbit: The Battle of the Five Armies (2014)                          61\n",
      "Paper Towns (2015)                                                        55\n",
      "Big Eyes (2014)                                                           72\n",
      "Maggie (2015)                                                             54\n",
      "Focus (2015)                                                              57\n",
      "The Second Best Exotic Marigold Hotel (2015)                              62\n",
      "The 100-Year-Old Man Who Climbed Out the Window and Disappeared (2015)    67\n",
      "Escobar: Paradise Lost (2015)                                             52\n",
      "Into the Woods (2014)                                                     71\n",
      "Inherent Vice (2014)                                                      73\n",
      "Magic Mike XXL (2015)                                                     62\n",
      "Woman in Gold (2015)                                                      52\n",
      "The Last Five Years (2015)                                                60\n",
      "Jurassic World (2015)                                                     71\n",
      "Minions (2015)                                                            54\n",
      "Spare Parts (2015)                                                        52\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "series_greater_than_50 = series_custom[series_custom > 50]\n",
    "criteria_one = series_custom > 50\n",
    "criteria_two = series_custom < 75\n",
    "both_criteria = series_custom[criteria_one & criteria_two]\n",
    "print(both_criteria)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FILM\n",
      "Avengers: Age of Ultron (2015)                    80.0\n",
      "Cinderella (2015)                                 82.5\n",
      "Ant-Man (2015)                                    85.0\n",
      "Do You Believe? (2015)                            51.0\n",
      "Hot Tub Time Machine 2 (2015)                     21.0\n",
      "The Water Diviner (2015)                          62.5\n",
      "Irrational Man (2015)                             47.5\n",
      "Top Five (2014)                                   75.0\n",
      "Shaun the Sheep Movie (2015)                      90.5\n",
      "Love & Mercy (2015)                               88.0\n",
      "Far From The Madding Crowd (2015)                 80.5\n",
      "Black Sea (2015)                                  71.0\n",
      "Leviathan (2014)                                  89.0\n",
      "Unbroken (2014)                                   60.5\n",
      "The Imitation Game (2014)                         91.0\n",
      "Taken 3 (2015)                                    27.5\n",
      "Ted 2 (2015)                                      52.0\n",
      "Southpaw (2015)                                   69.5\n",
      "Night at the Museum: Secret of the Tomb (2014)    54.0\n",
      "Pixels (2015)                                     35.5\n",
      "McFarland, USA (2015)                             84.0\n",
      "Insidious: Chapter 3 (2015)                       57.5\n",
      "The Man From U.N.C.L.E. (2015)                    74.0\n",
      "Run All Night (2015)                              59.5\n",
      "Trainwreck (2015)                                 79.5\n",
      "Selma (2014)                                      92.5\n",
      "Ex Machina (2015)                                 89.0\n",
      "Still Alice (2015)                                86.5\n",
      "Wild Tales (2014)                                 94.0\n",
      "The End of the Tour (2015)                        90.5\n",
      "                                                  ... \n",
      "Clouds of Sils Maria (2015)                       78.0\n",
      "Testament of Youth (2015)                         80.0\n",
      "Infinitely Polar Bear (2015)                      78.0\n",
      "Phoenix (2015)                                    90.0\n",
      "The Wolfpack (2015)                               78.5\n",
      "The Stanford Prison Experiment (2015)             85.5\n",
      "Tangerine (2015)                                  90.5\n",
      "Magic Mike XXL (2015)                             63.0\n",
      "Home (2015)                                       55.0\n",
      "The Wedding Ringer (2015)                         46.5\n",
      "Woman in Gold (2015)                              66.5\n",
      "The Last Five Years (2015)                        60.0\n",
      "Mission: Impossible â€“ Rogue Nation (2015)       91.0\n",
      "Amy (2015)                                        94.0\n",
      "Jurassic World (2015)                             76.0\n",
      "Minions (2015)                                    53.0\n",
      "Max (2015)                                        54.0\n",
      "Paul Blart: Mall Cop 2 (2015)                     20.5\n",
      "The Longest Ride (2015)                           52.0\n",
      "The Lazarus Effect (2015)                         18.5\n",
      "The Woman In Black 2 Angel of Death (2015)        23.5\n",
      "Danny Collins (2015)                              76.0\n",
      "Spare Parts (2015)                                67.5\n",
      "Serena (2015)                                     21.5\n",
      "Inside Out (2015)                                 94.0\n",
      "Mr. Holmes (2015)                                 82.5\n",
      "'71 (2015)                                        89.5\n",
      "Two Days, One Night (2014)                        87.5\n",
      "Gett: The Trial of Viviane Amsalem (2015)         90.5\n",
      "Kumiko, The Treasure Hunter (2015)                75.0\n",
      "Length: 146, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "rt_critics = Series(fandaogo['RottenTomatoes'].values, index=fandaogo['FILM'])\n",
    "rt_users = Series(fandaogo['RottenTomatoes_User'].values, index=fandaogo['FILM'])\n",
    "rt_mean = (rt_critics + rt_users)/2\n",
    "print(rt_mean)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
